import request from '@/utils/request'

const api = {
  getTree: '/targetManagement/tree',
  getDeclarationInfoDetail: `/declarationInfo/getDeclarationInfoDetail/`,
  getTargetDeclarationRecordList: '/targetDeclarationRecord/page',
  getTargetDeclarationRecordDetail: '/targetDeclarationRecord/',
  submitDeclare: '/targetDeclarationRecord',
  targetManagement: '/targetManagement/',
  getCaseList: '/individualCase/list',
  deleteCase: '/individualCase/delete',
  socialOrganizationTypeList: '/system/user/listCompany',
  addCase: '/individualCase/add',
  getFiles: '/targetDeclarationRecordFile/getFile/',
  getFilesBefore: '/targetDeclarationRecordFile/getFiles/',
  getAllFile: '/declarationInfo/getAllFile'
}

// 左侧指标树
export function getTree (params) {
  return request({
    url: api.getTree,
    method: 'get',
    params
  })
}

// 详情
export function getDeclarationInfoDetail (id) {
  return request({
    url: api.getDeclarationInfoDetail + id,
    method: 'get'
  })
}

// 指标列表
export function getTargetDeclarationRecordList (params) {
  return request({
    url: api.getTargetDeclarationRecordList,
    method: 'get',
    params
  })
}

// 根据指标填报记录id查询指标填报详情
export function getTargetDeclarationRecordDetail (id) {
  return request({
    url: api.getTargetDeclarationRecordDetail + id,
    method: 'get'
  })
}

// 填报指标
export function submitDeclare (data) {
  return request({
    url: api.submitDeclare,
    method: 'post',
    data
  })
}

// 填报指标
export function editDeclare (data) {
  return request({
    url: api.submitDeclare,
    method: 'put',
    data
  })
}

// 指标详情
export function getTargetManagement (id) {
  return request({
    url: api.targetManagement + id,
    method: 'get'
  })
}

// 个案管理列表
export function getCaseList (params) {
  return request({
    url: api.getCaseList,
    method: 'get',
    params
  })
}

// 个案管理删除
export function deleteCase (data) {
  return request({
    url: api.deleteCase,
    method: 'post',
    data
  })
}

// 社会组织名称列表
export function socialOrganizationTypeList () {
  return request({
    url: api.socialOrganizationTypeList,
    method: 'get'
  })
}

// 添加个案管理
export function addCase (data) {
  return request({
    url: api.addCase,
    method: 'post',
    data
  })
}

// 根据指标填报id查询合并后的文件
export function getFiles (targetDeclarationRecordId) {
  return request({
    url: api.getFiles + targetDeclarationRecordId,
    method: 'get'
  })
}

// 根据指标填报id查询历史文件
export function getFilesBefore (targetDeclarationRecordId) {
  return request({
    url: api.getFilesBefore + targetDeclarationRecordId,
    method: 'get'
  })
}

// 下载并合并文件
export function getAllFile (params) {
  return request({
    url: api.getAllFile,
    method: 'get',
    params
  })
}
